<?php
/**
 * Created by PhpStorm.
 * User: YD
 * Date: 2017/5/5
 * Time: 15:41
 */

namespace app\home\common;


class Pagetwo
{
    private $pages;       //总共有多少页
    private $module;       //模块
    private $controller;  //控制器
    private $action;      //方法
    private $current; //当前页
  public function __construct($totalcounts,$current){
      $request=request()->instance();
      $this->module=$request->module();
      $this->controller=$request->controller();
      $this->action=$request->action();
      $this->pages=$totalcounts;
      $this->current=$current;
  }
    public function show(){
        $module=$this->module;
        $controller=$this->controller;
        $action=$this->action;
        $currents=$this->current;
        $mvc=$module.'/'.$controller.'/'.$action;
        $str='<nav aria-label="Page navigation"><ul class="pagination"><li>';
        $prev='<a href="'.URL("{$mvc}",['p'=>$currents-1,'tableName'=>"{$_GET['tableName']}"]).'" aria-label="Previous"><span aria-hidden="true">&laquo;</span></a></li>';
//        $current1=$current-1;
//        $first='<li><a href="'.URL("{$mvc}",['p'=>$current1]).'">'.$current1.'</a></li>';
        $current='<li><a style="background:#EEE" href="'.URL("{$mvc}",['p'=>$currents,'tableName'=>"{$_GET['tableName']}"]).'">'.$currents.'</a></li>';
        $current2=$currents+1;
        $third='<li><a href="'.URL("{$mvc}",['p'=>$current2,'tableName'=>"{$_GET['tableName']}"]).'">'.$current2.'</a></li>';
        $next='<li><a href="'.URL("{$mvc}",['p'=>$current2,'tableName'=>"{$_GET['tableName']}"]).'" aria-label="Next"><span aria-hidden="true">&raquo;</span></a></li>';
        $end='</ul></nav>';
        $total="<span>总共有 {$this->pages} 页</span>";
        $pager=$str.$prev.$current.$third.$next.$end.$total;
        return $pager;
    }
}